package com.atao.baokede.service.serviceImpl;

import com.atao.baokede.mapper.AiMapper;
import com.atao.baokede.pojo.AiDialogue;
import com.atao.baokede.service.AiService;
import com.atao.baokede.utils.ThreadLocalUtil;
import org.springframework.ai.chat.model.ChatResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class AiServiceImpl implements AiService {
    @Autowired
    private AiMapper aiMapper;
    @Override
    public void deleteAllChat() {
        Map<String, Object> map = ThreadLocalUtil.get();
        Long userId = ((Number) map.get("id")).longValue();
        aiMapper.deleteAllChat(userId);
    }

    @Override
    public List<AiDialogue> getAllChat() {
        Map<String, Object> map = ThreadLocalUtil.get();
        Long userId = ((Number) map.get("id")).longValue();
        return aiMapper.getAllChat(userId);
    }
}
